Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's an initial version of a CMake build system. I've left some TODOs in the CMakeLists.txt which I'll look at next but I think it might be enough to merge already. Of course, let me know if there's anything you want changed.
It successfully builds the SDL version for me locally on macOS 12 and Linux Mint 21.2, and in GitHub Actions on macOS 12 and Ubuntu 22.04.3.
My intention is that this would replace the SCons build system (see #1275) but you may want to give users time to transition before removing the SCons build system. For now, I've updated the CI workflow to build using both SCons and CMake.
In the SCons and QMake builds I see you used globs to accumulate all the *.cpp files. CMake can do this but I've read it's not recommended. One reason given is that if you don't modify the CMakeLists.txt file (or a file it includes), CMake won't know that it should rescan to find new files. Therefore I've listed all the *.cpp files individually. I've put them in a separate file, cmake/CLK_SOURCES.cmake, so as not to clutter up the main CMakeLists.txt file.
I wasn't sure whether you preferred to edit the file list manually or have it done automatically. The bash script cmake/generate_CLK_SOURCES can be used to regenerate cmake/CLK_SOURCES.cmake. Depending on how long the SCons build system sticks around, the script could be modified to update the file list in the SConstruct file as well, and conceivably the QMake clksignal.pro as well.
Do you remember why the SCons build links with libpthread? It was added with a lot of other stuff in c0055a5 but it builds fine without it on macOS and Linux Mint and Ubuntu, so I didn't add it to the CMake build, but I can if it's needed.
It's customary to list the project version in the
project
line of the CMakeLists.txt, so I have. That makes one more place where the version would need to be updated each time. Later, I'd like to improve things so that there's only one place where the version number needs to be set, such as a simple VERSION text file that each of the build systems could read and use.Where the SCons build used
-Wall
, I've used-Wall -Wextra
in the CMake build. This shows a few warnings currently that you might want to look at to see if they're important. Might want to add-Wpedantic
as well but that shows a lot more (possibly irrelevant) warnings with your current code.The SCons build used
-O2
optimization flags. The CMake build does not specify them and leaves it to the user to select the build type they want. For example,-DCMAKE_BUILD_TYPE=Release
uses-O3
or-DCMAKE_BUILD_TYPE=MinSizeRel
uses-Os
.I haven't documented the CMake build process here yet; I would do that after #1323 is dealt with.